package com.cy.cykh.app.view.fragment

import android.view.View
import com.cy.cykh.app.cdyapp.R
import com.cy.cykh.app.view.activity.OtherActivity
import com.cy.cykh.app.view.base.BaseFragment
import kotlinx.android.synthetic.main.fragment_home_pager.*
import com.cy.cykh.app.widget.loading.ShapeLoadingDialog



/**
 * @author Administrator
 * @FileName
 * @date 2019/1/2 17:29
 */
class HomePagerFragment : BaseFragment() {

    private var shapeLoadingDialog: ShapeLoadingDialog? = null
    private var loadingDialog: ProgressFragment? = null
    override fun getContentViewID(): Int {
        return R.layout.fragment_home_pager
    }

    override fun initView() {
        cv_a.setOnClickListener(mOnclick)
        cv_b.setOnClickListener(mOnclick)
        cv_c.setOnClickListener(mOnclick)
        cv_ic.setOnClickListener(mOnclick)
        cv_d.setOnClickListener(mOnclick)
        cv_b.setOnClickListener(mOnclick)
        cv_h.setOnClickListener(mOnclick)
        cv_i.setOnClickListener(mOnclick)
        cv_g.setOnClickListener(mOnclick)

        shapeLoadingDialog = ShapeLoadingDialog.Builder(activity)
                .loadText("加载中...")
                .build()
        loadingDialog=ProgressFragment.newInstance()
    }

    companion object {
        @JvmStatic
        fun newInstance() = HomePagerFragment()
    }

    /**
     *监听
     *
     */
    private var mOnclick = View.OnClickListener { view ->
        if (view != null) {
            when (view.id) {
                R.id.cv_a -> {
                    //得分查询
                   shapeLoadingDialog!!.show()

                }
                R.id.cv_b -> {
                    //奖扣查询
                    shapeLoadingDialog!!.dismiss()
                }
                R.id.cv_c -> {
                    //奖金查询
                    GoActivity(OtherActivity::class.java)
                }
                R.id.cv_ic -> {
                    //人才检索
                    showProgress()
                }
                R.id.cv_d -> {
                    //更多
                }
                R.id.cv_h -> {
                    //绩效
                }
                R.id.cv_i -> {
                    //帮助
                }
                R.id.cv_g -> {
                    //结果公布
                }
            }
        }
    }


    private fun showProgress() {
        loadingDialog!!.show(fragmentManager,"pageLoad")
    }

    private fun dismissProgress() {
        loadingDialog!!.dismiss()
    }

}